package threshold;

import java.util.Arrays;

/**
 * @Author wujiaming
 * @Description TODO
 * @Date 2023-03-01 20:45
 * @Version 1.0
 */
public class Force {

    int partition(int[] nums,int low,int high){
        int pivot = nums[low];
        while(low<high){
            while(low<high && nums[high]>=pivot){high--;}
            nums[low] = nums[high];
            while(low<high && nums[low]<=pivot){low++;}
            nums[high] = nums[low];
        }
        nums[low] = pivot;
        return low;
    }

    void quickSort(int[] nums,int low,int high){
        if(low<high){
            int pivotPos = partition(nums, low, high);
            quickSort(nums,low,pivotPos);
            quickSort(nums,pivotPos+1,high);
        }
    }

    public static void main(String[] args) {
        int[] nums = {12,9,6,100,0,4};
        Force force = new Force();
        force.quickSort(nums,0,nums.length-1);
        System.out.println(Arrays.toString(nums));
        int sum =0;
        for(int i=nums.length-1,count=0;;i--){
            sum +=nums[i];
            count++;
            if(count==3){
                System.out.println(sum);
                break;
            }
        }
    }
}
